<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include2923 :: header('工程概算台账新增')"/>
</head>
<body>
<form action="" class="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label required">工程编码</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input"  name="pronum" lay-verify="pronum" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">工程名称</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|proname" name="proname" type="text">
                    </div>
                </div>
                <div class="layui-form-item" id="typeItem">
                    <label class="layui-form-label">概算书类型</label>
                    <div class="layui-input-block">
                        <select id="type" name="type">
                            <option value="1">基建类</option>
                            <option value="2">业扩类</option>
                            <option value="3">技改类</option>
                            <option value="4">大修类</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">概算书日期</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|bookdate" name="bookdate"
                               id="bookdate"
                               placeholder="请选择概算书日期"
                               type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">批次</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|batchnum" name="batchnum" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">建筑工程费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|jzgcf" name="jzgcf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">安装工程费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|azgcf" name="azgcf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">设备购置费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|sbgzf" name="sbgzf"
                               type="number">
                    </div>
                </div>

<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label required">安装工程费(元)</label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <input autocomplete="off" class="layui-input" lay-verify="required|azgcf" name="azgcf"-->
<!--                               type="number">-->
<!--                    </div>-->
<!--                </div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label required">其他费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|qtf" name="qtf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">总投资(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|total" name="total"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">建设场地征用及清理费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|jscdzyjglf" name="jscdzyjglf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">项目建设管理费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|xmjsglf" name="xmjsglf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">建设期贷款利息(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|jsqdklx" name="jsqdklx"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">项目管理经费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|xmgljf" name="xmgljf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">工程监理费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|gcjlf" name="gcjlf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">施工费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|sgf" name="sgf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">项目前期工作费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|xmqqgzf" name="xmqqgzf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">勘察费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|kcf" name="kcf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">设计费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|sjf" name="sjf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">设计文件评审费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|sjwjpsf" name="sjwjpsf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">项目后评价费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|xmhpjf" name="xmhpjf"
                               type="number">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label required">工程保险费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|gcbxf" name="gcbxf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">施工过程造价咨询及竣工结算审核费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|jgjsshf" name="jgjsshf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">生产准备费(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|sczbf" name="sczbf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">带电作业(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|ddzyf" name="ddzyf"
                               type="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">甲供材(元)</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required|jgchjje" name="jgchjje"
                               type="number">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button class="layui-btn layui-btn-normal layui-btn-sm" lay-filter="infoProjectbudgetJs-save" lay-submit="" type="submit">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button class="layui-btn layui-btn-primary layui-btn-sm" type="reset">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<th:block th:include="include2923 :: footer"/>
<script>
    layui.use(['form', 'jquery'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#bookdate' //指定元素
            ,format: 'yyyy年MM月dd日'
        })


        var MODULE_PATH = rootPath + "/InfoProjectbudgetJsController/";

        form.verify({
            pronum: function (value) {
                var msg = "";
                $.ajax({
                    url: MODULE_PATH + 'checkOrderUniqueAdd',
                    data: "pronum=" + value,
                    dataType: 'json',
                    type: 'post',
                    async: false,
                    success: function (result) {
                        msg = result;
                    }
                });
                if (msg == 1) {
                    return "已有相同项目编码，请重新编号";
                }

            },
            jzgcf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '建筑工程费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            azgcf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '安装工程费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            sbgzf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '设备购置费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            qtf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '其他费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            total: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '总投资（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            jscdzyjglf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '建设场地征用及清理费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            xmjsglf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '项目建设管理费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            xmgljf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '项目管理经费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            gcjlf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '工程监理费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            sgf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '施工费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            xmqqgzf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '项目前期工作费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            kcf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '勘察费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            sjf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '设计费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            sjwjpsf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '设计文件评审费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            xmhpjf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '项目后评价费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            jsqdklx: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '建设期贷款利息（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            gcbxf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '工程保险费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            jgjsshf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '施工过程造价咨询及竣工结算审核费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            sczbf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '生产准备费（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            ddzyf: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '带电作业（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
            jgchjje: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[+-]?((\\d*(\\.\\d{1,2})$)|(\\d+$))").test(value)){
                    return '甲供材（元）金额输入不合法！(仅可输入整数或带两个小数点数字)';
                }
            },
        });


        form.on('submit(infoProjectbudgetJs-save)', function (data) {
            $.ajax({
                url: MODULE_PATH + 'add',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code == 200) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("infoProjectbudgetJs-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    })
</script>
</body>
</html>